home *** CD-ROM | disk | FTP | other *** search
- #include "screen.h"
-
- long IDLETICKS = (60*60*5);
-
- static Boolean forcedIdle = FALSE;
- static Point mouseNow,
- mouseLast = { 0, 0};
- static KeyMap keysNow,
- keysLast = { 0, 0, 0, 0};
-
- /*
- Returns TRUE if screen has been idle more than IDLETICKS ticks, else FALSE
- */
- Boolean idle(struct screen *screen) {
-
- GetMouse(&mouseNow);
- LocalToGlobal(&mouseNow);
- if (PtInRect(mouseNow,&screen->globalRect)) {
- if ( (abs(mouseNow.h-mouseLast.h)>4) || (abs(mouseNow.v-mouseNow.v)>4) ) {
- screen->idleSince = TickCount();
- mouseLast = mouseNow;
- } // mouse moved
- GetKeys(keysNow);
- if ( keysNow[0]!=keysLast[0] ||
- keysNow[1]!=keysLast[1] ||
- keysNow[2]!=keysLast[2] ||
- keysNow[3]!=keysLast[3] ) {
- keysLast[0]=keysNow[0];
- keysLast[1]=keysNow[1];
- keysLast[2]=keysNow[2];
- keysLast[3]=keysNow[3];
- screen->idleSince = TickCount();
- } // key pressed
- } // if mouse on screen
-
- if (screen->idleSince + IDLETICKS < TickCount())
- return TRUE;
- return FALSE;
- }
-
- /*
- Simulate the condition of the machine being idle. This forces the saver on.
- */
- void simulateidle(struct screen *screen) {
-
- screen->idleSince = TickCount() - (IDLETICKS-1);
- GetMouse(&mouseNow);
- LocalToGlobal(&mouseNow);
- if (PtInRect(mouseNow,&screen->globalRect)) {
- mouseLast=mouseNow;
- GetKeys(keysLast);
- }
- return;
- }